<template>
    <div class="order">
        <el-table :data="tableData" stripe style="width: 100%" height="500">
            <el-table-column prop="scriptWritingTitle" label="序号" width="180" type="index"/>
            <el-table-column prop="title" label="名称" width="180"/>
            <el-table-column prop="publisher" label="作者"/>
            <el-table-column prop="description" label="作品简介"/>

            <el-table-column prop="price" label="金额">
                <template #default="scope">
                    <span>{{ scope.row.price == null ? '免费' : scope.row.price }}</span>
                </template>
            </el-table-column>

            <el-table-column label="操作" width="150">
                <template #default="scope">

                    <el-button size="mini" type="primary" @click="buy(scope.$index, scope.row)" v-if="scope.row.price != null">购买</el-button>
                    <el-button v-else size="mini" type="primary" @click.stop="to_chakan(scope.row)">查看</el-button>

                    <el-button size="mini" type="danger" @click="handleDelete(scope.$index, scope.row)">删除</el-button>

                </template>
            </el-table-column>
        </el-table>
        <div style="text-align:right;margin-top:20px">
            <el-pagination
                    background
                    v-model:currentPage="currentPage1"

                    :total="total"
                    @size-change="handleSizeChange"
                    @current-change="handleCurrentChange"
            >
            </el-pagination>
        </div>
    </div>
</template>
<script>
    import {MyCollectionList} from "@/api/TradeInfo"
    import {CollectionDel} from "../../api/dsp/CollectionEdit";

    export default {
        data() {
            return {
                currentPage1: 1,
                total:undefined,
                tableData: [],
                scanType: 2,//1：订单 2：交易
            };
        },
        created() {
            this.getList()
        },
        methods: {
            getList() {
                MyCollectionList().then((res) => {
                    this.tableData=res.data.list
                    console.log(res.data)
                    this.total=res.data.total*10
                })
            },
            buy(index,row){
                console.log(index,row)
                this.$router.push({path:'/copyrightTrade',query:{id:row.id}})
            },
            to_chakan(item){
              this.$router.push({path:'/dsp/dspDetail',query:{id:item.id}})
            },
            handleDelete(index,row) {
                CollectionDel({scriptWritingId:row.id,selectType:1}).then(res=>{
                    this.getList()
                })
            },
            handleSizeChange() {
            },
            handleCurrentChange() {
            },
        },
    };
</script>
<style lang="scss" scoped>

</style>
